﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Abp.Auditing;
using AbpZeroTemplate.Notifications;
using AbpZeroTemplate.Notifications.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>通知
    /// </summary>
    [Area("Admin")]
    [Route("Admin/Notification/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize]
    public class NotificationController : AbpZeroTemplateControllerBase
    {
        private readonly INotificationAppService _notificationAppService;
        /// <summary>
        /// </summary>
        public NotificationController(INotificationAppService notificationAppService)
        {
            _notificationAppService = notificationAppService;
        }

        /// <summary>获取用户通知
        /// </summary>
        [HttpGet]
        [DisableAuditing]
        public async Task<GetNotificationsOutput> GetUserNotifications(GetUserNotificationsInput input)
        {
            return await _notificationAppService.GetUserNotifications(input);
        }

        /// <summary>设置全部通知为已读
        /// </summary>
        [HttpPost]
        public async Task SetAllNotificationsAsRead()
        {
            await _notificationAppService.SetAllNotificationsAsRead();
        }

        /// <summary>设置为已读
        /// </summary>
        [HttpPost]
        public async Task SetNotificationAsRead([FromBody]EntityDto<Guid> input)
        {
            await _notificationAppService.SetAllNotificationsAsRead();
        }

        /// <summary>获取通知的配置
        /// </summary>
        [HttpGet]
        public async Task<GetNotificationSettingsOutput> GetNotificationSettings()
        {
            return await _notificationAppService.GetNotificationSettings();
        }

        /// <summary>更新通知配置
        /// </summary>
        [HttpPost]
        public async Task UpdateNotificationSettings([FromBody]UpdateNotificationSettingsInput input)
        {
            await _notificationAppService.UpdateNotificationSettings(input);
        }


    }
}
